from django.template import RequestContext
from django.shortcuts import render_to_response
from models import Post
from models import Catergorie
from models import Setting
from models import Website
from models import Page


def index(request):
    post=Post.objects.all()
    categories=Catergorie.objects.all()
    website=Website.objects.all()
    setting=Setting.objects.all()
    pages = Page.objects.all()
    return render_to_response('index.html', {'post':post,'pages':pages,'recpost':post,'category' : categories, 'website' :website, 'setting':setting},RequestContext(request))
	
def post(request, id) :
   post = Post.objects.filter(catergories_id=id)
   categories=Catergorie.objects.all()
   website=Website.objects.all()
   pages = Page.objects.all()
   return render_to_response('index.html', {'post':post,'pages':pages,'recpost':post,'category' : categories, 'website' :website},RequestContext(request))
   
def thepost(request, pid) :
   post = Post.objects.filter(id=pid)
   categories=Catergorie.objects.all()
   website=Website.objects.all()
   pages = Page.objects.all()
   return render_to_response('index.html', {'post':post,'pages':pages,'recpost':post,'category' : categories, 'website' :website},RequestContext(request))
   
def page(request,pageid) :
   page = Page.objects.filter(id=pageid)
   pages = Page.objects.all()
   post=Post.objects.all()
   categories=Catergorie.objects.all()
   website=Website.objects.all()
   return render_to_response('index.html', {'page':page,'pages':pages,'recpost':post,'category' : categories, 'website' :website},RequestContext(request))